/*******************************************************************************
* 
* LzmaHelper Test
* 
* 
******************************************************************************/
#include "stdafx.h"
#include "CppUnitTest.h"

#include "../common/common.h"

using namespace std;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace ut
{
	TEST_CLASS(LzmaTest)
	{
	public:
		
		TEST_METHOD(LzmaTestMethod1)
		{
            unsigned char itest[10] = {0};
            unsigned char otest[30] = {0};
            unsigned char dtest[10];
            size_t olen = 30;
            size_t dlen = 10;

            bool ret = LzmaHelper::compress(itest, 10, otest, &olen);
            Assert::AreEqual<bool>(ret, true, L"failed to compress");
            LOG_DEBUG("compressed from %d to %d", 10, olen);

            ret = LzmaHelper::decompress(otest, olen, dtest, &dlen);
            Assert::AreEqual<bool>(ret, true, L"failed to decompress");
            LOG_DEBUG("decompressed from %d to %d", olen, dlen);

            Assert::AreEqual(memcmp(itest, dtest, 10), 0);
		}

		TEST_METHOD(LzmaTestMethod2)
		{
            bool ret = LzmaHelper::compress(L"d:/source.bin", L"d:/dest.bin");
            Assert::AreEqual<bool>(ret, true, L"failed to compress");

            //ret = LzmaHelper::decompress(L"d:/dest.bin", L"d:/decompress.bin");
            //Assert::AreEqual<bool>(ret, true, L"failed to decompress");

            size_t size = 0;
            ret = LzmaHelper::decompress(L"d:/dest.bin", L"d:/decompress2.bin", &size);
            Assert::AreEqual<bool>(ret, true, L"failed to decompress");

            LOG_DEBUG("input: 25852281, output: %d", size);
		}
	};
}